Repository navigation
Letterbox chef-supplied thumbnails to 400×225 PNG - #888
Conversation
rtibbles
left a comment
There was a problem hiding this comment.
Feels a little too specific in terms of the utility - better to make it slightly more general and have a thumbnail specific preset configuration to pass around.
|
|
||
|
|
||
| class ImageConversionContextMetadata(ContextMetadata): | ||
| thumbnail: bool = False |
There was a problem hiding this comment.
Feels like it would be simpler for this just to be width and height properties here? We can then have a constant that encodes the thumbnail dimensions that gets passed around, and this just becomes a generic resize utility.
maintain_aspect_ratio as a boolean is then used to determine whether to letterbox or not - if both are given, and it's set, we apply letterboxing.
There was a problem hiding this comment.
Done in the amended commit:
resize_image(image, width, height, maintain_aspect_ratio)inutils/images.pyreplacesletterbox_thumbnail: letterboxes when both dimensions are given andmaintain_aspect_ratiois set, scales proportionally when one is given, stretches when it is unset.ImageConversionContextMetadatanow carrieswidth/height/maintain_aspect_ratio; cache key suffix is:{w}x{h}:fit|stretch.THUMBNAIL_RESIZEconstant inutils/images.pyis the thumbnail preset;ThumbnailFileandBase64ImageFilepass it as pipeline context.- Searched for every
thumbnailcontext flag use: 2 File classes, 5 test call sites — all switched toTHUMBNAIL_RESIZE. - Added tests for the stretch and single-dimension paths.
- ImageConversionHandler gains a `thumbnail` context flag: scale down to fit, centre on a transparent 400×225 RGBA canvas (matches learningequality/studio#6351) - ThumbnailFile and Base64ImageFile set the flag; exercise and extracted thumbnails are unchanged - TiledThumbnailFile tiles the unconverted sources Closes learningequality#882 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ab83179 to
68593f1
Compare
|
Quick check on rtibblesbot's work on this PR: react 👍 helpful · 😕 mixed · 👎 not helpful. Reply with anything specific. |
Summary
Studio now stores every thumbnail as a 400×225 PNG and converts at publish only for older ricecooker versions.
ThumbnailFileandBase64ImageFilescale down to fit, centre on a transparent 400×225 canvas and upload as PNG.ImageConversionHandlertakes genericwidth/height/maintain_aspect_ratiocontext;THUMBNAIL_RESIZEpasses 400×225 with letterboxing._ExerciseBase64ImageFileno longer inherits fromBase64ImageFile, so exercise images stay unconverted.TiledThumbnailFiletiles the unconverted chef images, not the letterboxed ones.References
Closes #882. Studio counterpart: learningequality/studio#6351.
Reviewer guidance
Suggested review: Full code review, then manual QA once the reviewer sets Needs QA.
Unit tests on CI cover landscape, portrait, smaller-than-target, transparent, 16-bit grayscale and EXIF-rotated sources.
AI usage
Used Claude Code to plan and implement the conversion and its tests. Verified with the full test suite and prek.
Written by rtibblesbot, an LLM-based coding agent.
🟡 Waiting for feedback
WAITING · on a reviewerLast updated: 2026-11-07 03:47 UTC